package com.zhi_cloud_plat2.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhi_cloud_plat2.common.PageResult;
import com.zhi_cloud_plat2.mapper.TbItemMapper;
import com.zhi_cloud_plat2.pojo.TbItem;
import com.zhi_cloud_plat2.pojo.TbItemExample;
@Service
public class ItemserviceImpl implements ItemService {
	@Resource
	private TbItemMapper tbItemMapper;
	@Override
	public TbItem getItemById(Long id) {
		TbItem item = tbItemMapper.selectByPrimaryKey(id);
		System.out.println("lall啦啦啦啦了咯卡了附件里是打开大家分厘卡时间来的进来咯就送大礼咖啡碱阿历克斯大家flak家里");
		System.out.println(id);
		return item;
	}
	@Override
	public PageResult getItemList(int pageN, int rows) {
		// TODO Auto-generated method stub
		//设置分页参数 pageN：当前页码  rows:每页数量
		PageHelper.startPage(pageN, rows);
		//查询全部数据
		TbItemExample tbItemExample = new TbItemExample();
		List<TbItem> tbItemList = tbItemMapper.selectByExample(tbItemExample);
		//将查询结果tbItemList通过PageInfo处理，并得到分页数据
		PageInfo<TbItem> pageInfo = new PageInfo<>(tbItemList);
		
		//将分页数据封装到自定义的PageResul中
		List<TbItem> list = pageInfo.getList();
		PageResult pageResult =new PageResult();
		pageResult.setRows(list);
		pageResult.setTotal(pageInfo.getTotal());
		return pageResult;
	}
}
